﻿using Coldairarrow.IBusiness.BTB_StaffUsers;
using Coldairarrow.Util;
using Coldairarrow.Util.DTO.OnlineChat;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Coldairarrow.Api.Controllers.FrontStage.InstantMessag
{
    [Route("/FrontStage/[controller]/[action]")]
    public class InstantMessagController : BaseApiController
    {
        readonly IUserOnlineChatBusiness _userOnlineChatBusiness;
        public InstantMessagController(IUserOnlineChatBusiness userOnlineChatBusiness)
        {
            _userOnlineChatBusiness = userOnlineChatBusiness;
        }

        /// <summary>
        ///前台 —— 游客获取临时游客Id
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        [AllowAnonymous]
        public object GetTheUserId()
        {
            return _userOnlineChatBusiness.GetRUserId();
        }

        /// <summary>
        /// 前台 —— 用户进入房间
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        [AllowAnonymous]
        public async Task<GetRoomDTO> RoomSava([FromBody] UserToRoomDTO input)
        {
            return await _userOnlineChatBusiness.UserToRoomAsync(input);
        }

        /// <summary>
        /// 前台 —— 获取用户聊天历史记录（分页）
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        [AllowAnonymous]
        public async Task<ChatLogListDTO> GetUserMassageLog0([FromBody] GetMassageDTO input)
        {
            return await _userOnlineChatBusiness.GetUserMessageLogAsync(input);
        }

        /// <summary>
        /// 前台 —— 获取用户未读消息数量
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        [AllowAnonymous]
        public async Task GetUserUnReadCountMessage0([FromBody] UserToRoomDTO input)
        {
            await _userOnlineChatBusiness.UserGetUnReadCountAsync(input);
        }

        /// <summary>
        /// 前台 —— 用户发送聊天消息
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        [AllowAnonymous]
        public async Task SendMessages0(UserSendChatDTO input)
        {
            await _userOnlineChatBusiness.UserSendMessageAsync(input);
        }


        /// <summary>
        /// TRTC_获取房间用户信息
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        [AllowAnonymous]
        public async Task<PTUDTO> GetUserData(GTUDTO input)
        {

            PTUDTO data = await _userOnlineChatBusiness.GetUserDataAsnyc(input);

            return data;
        }

        /// <summary>
        /// 获取OLV
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public List<OnLinkUserDTO> GetOLVUserList()
        {
            return _userOnlineChatBusiness.GetOLUserList();                    
        }


        /// <summary>
        /// 获取OLV1
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public List<CServiceDTO> GetOLVSUserList()
        {
            return _userOnlineChatBusiness.GetOLSUserList();
        }

        /// <summary>
        /// 移除OLV1
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public void ClearOLVSUserList()
        {
            _userOnlineChatBusiness.ClearOLVSUserList();
        }


        /// <summary>
        /// 移除OLV
        /// </summary>
        [HttpPost]
        public void DELOLVUser(List<string> ids)
        {
            _userOnlineChatBusiness.DELOLUser(ids);
        }


        /// <summary>
        /// 移除所有OLV
        /// </summary>
        [HttpPost]
        public void ClearOLVUser()
        {
            _userOnlineChatBusiness.ClearOLVUser();
        }
    }
}
